package xin.marcher.wind.process.enums;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.HashSet;
import java.util.Set;

/**
 * 调用方式
 *
 * 
 * @version 1.0
 */
@Getter
public enum InvokeMethodEnum {

    SYNC("SYNC","同步"),
    ASYNC("ASYNC","异步");

    private String code;
    private String desc;

    InvokeMethodEnum(String code,String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static Set<String> allowableValues() {
        Set<String> allowableValues = new HashSet<>(values().length);
        for (InvokeMethodEnum typeEnum : values()) {
            allowableValues.add(typeEnum.getCode());
        }
        return allowableValues;
    }

    public static InvokeMethodEnum getByCode(String code) {
        if(StringUtils.isEmpty(code)) {
            return null;
        }

        for (InvokeMethodEnum element : InvokeMethodEnum.values()) {
            if (code.equals(element.getCode())) {
                return element;
            }
        }
        return null;
    }
}